import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import NotFound from '../pages/home/notFound/index';
import Redirect from '../pages/home/redirect';
import Empty from '../pages/home/notFound/empty';
import Menu from '../pages/menu/menu';
export type RouterType = RouteRecordRaw & { chname?: string; icon?: string; children?: any };

export const longClassData = [
  {
    chname: '触达数据',
    name: 'longRachData',
    path: `/dataBoard/longRachData`,
    component: () => import('../pages/longClass/touch')
  },
  {
    chname: '行课数据',
    name: 'longBehaviorData',
    path: `/dataBoard/longBehaviorData`,
    component: () => import('../pages/longClass/plan')
  },
  {
    chname: '转换数据',
    name: 'longChangeData',
    path: `/dataBoard/longChangeData`,
    component: () => import('../pages/longClass/resubmit')
  }
];

export const shortClassData = [
  {
    chname: '触达数据',
    name: 'shortRachData',
    path: `/dataBoard/shortRachData`,
    component: () => import('../pages/shortClass/touch')
  },
  {
    chname: '行课数据',
    name: 'shortBehaviorData',
    path: `/dataBoard/shortBehaviorData`,
    component: () => import('../pages/shortClass/plan')
  },
  {
    chname: '转化数据',
    name: 'shortChangeData',
    path: `/dataBoard/shortChangeData`,
    component: () => import('../pages/shortClass/resubmit')
  }
];

const homeRouter = [
  {
    name: 'home',
    path: '/',
    component: () => import('../pages/menu/menu'),
    children: (
      [
        {
          name: 'introduce',
          chname: '介绍',
          path: '/',
          component: () => import('../pages/home/introduce')
        },
        {
          name: 'select',
          chname: '选择',
          path: '/select',
          component: () => import('../pages/home/select')
        }
      ] as RouterType[]
    ).concat(longClassData, shortClassData)
  }
];

export const routes: RouteRecordRaw[] = (homeRouter as RouteRecordRaw[]).concat([
  {
    name: 'redirect', // 首页
    path: '/redirect',
    component: Redirect
  },
  {
    name: 'notFound',
    path: '/:pathMatch(.*)*',
    component: NotFound
  }
]);

export const router = createRouter({
  history: createWebHashHistory(),
  // history: createWebHashHistory(import.meta.env.BASE_URL), // es2019编译目标下import.env不支持
  routes
});

export default router;
